<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/WEB-INF/common/public.jspf"%>
<%@ include file="/WEB-INF/common/easyui.jspf"%>

<script type="text/javascript">
	$(function() {
		$("#code").click(function(){
			$("#code").attr("src","/signin/verify/verifycode.jpg?time="+new Date());
		})
		
		$("#form").form("disableValidation");
		$("#login").dialog({
			title:"登录",
			resizable:true,
			modal:true,
			closable:false,
			draggable:false,
			buttons:[
				{
					text:"登录",
					handler:function(){
						$("#form").form("enableValidation");
						if($("#form").form("validate")){
							var code=$("#kaptchaCode").val();
							$.ajax({
								type:"POST",
								url: "/signin/verify/"+code,
								dataType:"json",
								success: function(msg){
									var tId=$("#tId").val();
									var tPassword=$("#tPassword").val();
								    if(msg.success){
								    	
								    	$.ajax({
								    		type:"post",
								    		url:"/signin/teacher/login",
								    		dataType:"json",
								    		data:"tId="+tId+"&tPassword="+tPassword,
								    		success:function(msg){
								    			if(msg.success){
								    				location.href="/signin/loginOk";
								    			}else{
								    				$("#err").text(msg.msg);
								    			}
								    		}
								    		
								    	});
								    }else{
								    	
								    	$("#err").text(msg.msg);
								    	
								    	$("#code").attr("src","/signin/verify/verifycode.jpg?time="+new Date())
								    }
								}
								
							});
							
						
						}
						
					}
				},
				{
					text:"重置",
					handler:function(){
						$("#form").form("reset");
					}
				}
			]
			
		});
		
	})
</script>
<title>登录</title>
</head>

<body>
	<div id="login" class="easyui-dialog" 
		style="width: 320px; height: 250px;padding: 20px;">
		<form id="form" method="post" action="/signin/teacher/login" >
			
			<div>
				<label for="tId">账 &nbsp;号:</label> <input id="tId" class="easyui-validatebox"
					type="text" name="tId" data-options="required:true,missingMessage:'账号不能为空'"  />
					
			</div>
			<br />

			<div>
				<label for="tPassword">密 &nbsp;码:</label> <input id="tPassword" class="easyui-validatebox"
					type="password" name="tPassword" data-options="required:true,missingMessage:'密码不能为空'" />
			</div>
			<br />
			<div>
				<label for="kaptchaCode">验证码:</label> <input id="kaptchaCode" class="easyui-validatebox" size=4 length=4
					type="text" name="kaptchaCode" data-options="required:true,missingMessage:'验证码不能为空'" />
					<img id="code" src="/signin/verify/verifycode.jpg"/>
			</div>
			
			<div id="msg">
				<font color='red' id='err'></font>
			</div>
			
			

		</form>

	</div>

</body>

</html>